﻿@{
    var act = Request.QueryString["act"];
    PageAdmin.BLL.PluginInfo pluginInfo = ViewBag.PluginInfo;
    var pluginName = pluginInfo.PluginName;
    var version = pluginInfo.Version;
}

<div class="main">
    <ul class="breadcrumb">
        <li><a>插件</a></li>
        <li>@pluginInfo.Name</li>
    </ul>
    <div class=" open-remark  hide alert alert-warning">
        <span class="help-block">
            <i class="fa fa-info-circle"></i>说明：<br />
            1、插件的安装会导致网站重启，建议在网站访客少的时段进行操作。<br />
            2、后台插件默认安装在我的工作台>>我的应用下，安装后可以在系统管理>>管理菜单中调整位置。<br />
            3、会员插件默认安装在我的账户>>我的菜单，安装后可以在系统管理>>会员菜单中调整位置。<br />
            4、插件安装完毕后，刷新整个网站页面即可看到新添加的插件菜单。<br />
            <span style="color:#ff0000">5、插件将会直接将代码安装到网站服务器，非官方认证的插件请谨慎安装，造成后果自行负责。</span>
        </span>
    </div>

    <div class="close-remark  hide alert alert-warning">
        <span class="help-block">
            <i class="fa fa-info-circle"></i>说明：<br />
            1、插件的关闭会导致网站重启，建议在网站访客少的时段进行操作。<br />
            2、关闭插件会暂停插件菜单，再次安装时候会再重新开启，之前的数据还保留。<br />
            3、插件关闭后，刷新整个网站页面后插件菜单将不再显示。
        </span>
    </div>

    <div class="unload-remark hide alert alert-warning">
        <span class="help-block">
            <i class="fa fa-info-circle"></i>说明：<br />
            1、插件卸载会删除整个插件相关的菜单、文件和数据，且不可恢复。<br />
            2、如果插件中带有重要数据，请谨慎操作，建议您先做好数据库备份和网站备份。<br />
        </span>
    </div>



    <form method="post" id="_form"  data-custom-params="beforeSubmit:'PostCheck'">
        <div class="submit-footerbar">
            <label class="control-label"></label>
            <div class="controls">
                <input type="hidden" name="version" id="version" value="@Request.QueryString["version"]" />
                <input type="hidden" name="pluginName" id="pluginName" value="@Request.QueryString["pluginName"]" />
                <input type="hidden" name="act" id="act" value="@Request.QueryString["act"]" />
                <button type="button" id="btn_submit" class="btn btn-sm btn-primary ui-pagePost" data-custom-params="url:'@Url.ActionUrl("Set")',beforeExecute:'PostBeforeCheck',confirmMsg:'是否确定？',callBack:'RefreshParent'">开启插件</button>
                <button type="button" class="btn btn-sm btn-default ui-closeDialog">取消</button>
            </div>
            </div>
    </form>
</div>

<script type="text/javascript">
    var act="@act";
    var pluginName = "@pluginName";
    var version = "@version";
    var $btnSubmit = $("#btn_submit");

    var $openRemark = $(".open-remark");
    var $closeRemark = $(".close-remark");
    var $unloadRemark = $(".unload-remark");

    switch(act)
    {
        case "open":
            $openRemark.removeClass("hide");
            $btnSubmit.text("开启插件");
            break;
        case "close":
            $closeRemark.removeClass("hide");
            $btnSubmit.text("关闭插件");
            break;

        case "uninstall":
            $unloadRemark.removeClass("hide");
            $btnSubmit.text("卸载插件");
            break;
    }

    if (act == "open")
    {
        if (pluginName == "" || version == "") {
            $btnSubmit.text("插件名称或版本号未定义").setAttribute("disabled", "disabled");
        }
    }

    function RefreshParent()
    {
        switch (act) {
            case "open":
                parent.CallBack();
                break;
            case "close":
                parent.CallBack();
                break;

            case "uninstall":
                parent.LoadData();
                break;
        }
        CloseDialog();
    }
</script>